﻿
function refreshVerifyCode() {
    var img = document.getElementById("verifyCode");
    var rd = randomWord(false, 16);
    img.src = MAIN_HOST + '/api/apiuser/GetLoginVerifyCode?id=' + rd;
}
function login() {
    var json = formSerializeJson("#form");
    if (!checkLength(json.LoginName, 3)) {
        layer.msg("用户名长度不正确");
        return;
    }
    if (!checkLength(json.LoginPwd, 3)) {
        layer.msg("密码长度不正确");
        return;
    }
    if (!checkLength(json.VerifyCode, 4, 6)) {
        layer.msg("验证码长度不正确");
        return;
    }
    jqJsonPost("/page/login", json, function (data) {
        console.log(data);
        layer.msg(data.msg);
        if (data.code == 0) {
            //登录成功
            window.location.href = MAIN_HOST;
        } else {
            $("input[type=reset]").trigger("click");
            refreshVerifyCode();
        }
    });
}